/**
 * Created by Administrator on 2017/3/23 0023.
 */

//用户注册
function userRegister() {
    var mobile = $(".userRegister .mobile").val();
    var code = $(".userRegister .code").val();
    var _username = $(".userRegister .username").val();
    var username= $.trim(_username);
    if(username.length<=0){
        $("#error").show();
        $("#errmsg").html("请输入非空昵称！");
        errorHide();
        return;
    }
    var password1 = $(".userRegister .password1").val();
    var password2 = $(".userRegister .password2").val();
    if(password1.length<6 || password1.length>20){
        $("#error").show();
        $("#errmsg").html("请输入6-18位密码！");
        errorHide();
        return;
    };
    $.ajax({
        type: "POST",
        url: "http://zbstest.guochengic.com/home/register/register",
        data: {
            "username": mobile,
            "nickname": username,
            "code": code,
            "password": password1,
            "validatePwd": password2
        },
        success: function (res) {
            if (res.code == 0) {
                $("#suc").show();
                $("#sucmsg").html(res.msg);
                successHide();
                $(".userRegister").hide();
                return;
            } else {
                $("#error").show();
                $("#errmsg").html(res.msg);
                errorHide();
                return;
            }
        }
    });
};
